package com.lsh.payment.worker.task;

import com.alibaba.fastjson.JSON;
import com.lsh.payment.core.model.payenum.RefundTaskStatus;
import com.lsh.payment.core.model.payenum.RefundTaskType;
import com.lsh.payment.core.model.refund.RefundTask;
import com.lsh.payment.worker.service.RefundTaskJopService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Project Name: lsh-payment
 *
 * @author peter
 * @date 16/11/16
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
@Component
public class RefundApplyJop extends AbstractPayElasticJob {

    private Logger logger = LoggerFactory.getLogger(RefundApplyJop.class);

    @Autowired
    private RefundTaskJopService refundTaskJopService;

    @Override
    protected RefundTaskType getRefundTaskType() {
        return RefundTaskType.REFUND_START;
    }

    @Override
    protected Integer getDealTimes() {
        return 2;
    }

    @Override
    protected RefundTaskStatus getExcludeStatus() {
        return RefundTaskStatus.TASK_SUCCESS;
    }

    @Override
    protected Boolean processTask(RefundTask refundTask) {

        logger.info("【apply jop 处理任务】 {}", JSON.toJSONString(refundTask));
        return refundTaskJopService.dealRefundTaskApply(refundTask);
    }
}
